package cn.findviewbydream.vant.plugin;

import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.IconLoader;
import com.intellij.psi.PsiElement;
import com.intellij.psi.meta.PsiPresentableMetaData;
import com.intellij.psi.xml.XmlElement;
import com.intellij.spellchecker.FileLoader;
import com.intellij.xml.impl.BasicXmlAttributeDescriptor;
import com.intellij.xml.impl.XmlAttributeDescriptorEx;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import javax.swing.*;

/**
 * cn.findviewbydream.vant.plugin
 *
 * @author 白雨浓
 * date: 2019/11/11 16:01
 * content:
 */
public class VantAttributeDescriptor extends BasicXmlAttributeDescriptor implements XmlAttributeDescriptorEx, PsiPresentableMetaData {

    private static final Icon ICON = IconLoader.getIcon("/icons/vant.png");

    private String attributeName;
    private String[] attributeValues;

    public VantAttributeDescriptor(String attributeName, String[] attributeValues) {
        this.attributeName = attributeName;
        this.attributeValues = attributeValues;
    }

    @Nullable
    @Override
    public String getTypeName() {
        return "vant";
    }

    @Nullable
    @Override
    public Icon getIcon() {
        return ICON;
    }

    @Nullable
    @Override
    public String handleTargetRename(@NotNull String newTargetName) {
        return newTargetName;
    }

    @Override
    public PsiElement getValueDeclaration(XmlElement xmlElement, String value) {
        return super.getValueDeclaration(xmlElement, value);
    }

    @Override
    protected PsiElement getEnumeratedValueDeclaration(XmlElement xmlElement, String value) {
        return xmlElement;
    }

    @Override
    public boolean isRequired() {
        return false;
    }

    @Override
    public boolean hasIdType() {
        return false;
    }

    @Override
    public boolean hasIdRefType() {
        return false;
    }

    @Override
    public boolean isEnumerated() {
        return false;
    }

    @Override
    public PsiElement getDeclaration() {
        return null;
    }

    @Override
    public String getName() {
        return attributeName;
    }

    @Override
    public void init(PsiElement psiElement) {

    }

    @Override
    public boolean isFixed() {
        return false;
    }

    @Override
    public String getDefaultValue() {
        return null;
    }

    @Override
    public String[] getEnumeratedValues() {
        return attributeValues;
    }
}
